<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateAuthorizersTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('authorizers', function(Blueprint $table)
		{
			$table->increments('id');
			$table->string('authorizer_appid', 190)->default('')->index('ewm_authorizers_authorizer_appid_index')->comment('授权公众号App Id');
			$table->string('authorizer_access_token')->default('')->comment('授权公众号access_token，！拿到就可以代公众号调用Api了');
			$table->string('authorizer_refresh_token')->default('')->comment('妥善保存，只有授权时才有');
			$table->string('auth_code')->default('')->comment('类似 oauth 的 code， 用来核对后台已更新授权');
			$table->string('jsapi_ticket')->nullable()->comment('jssdk所需的 ticket 用于 signature 签名');
			$table->string('merchant_id')->nullable()->comment('公众号微信支付商户ID');
			$table->string('merchant_key')->nullable()->comment('公众号微信支付商户KEY');
			$table->string('cert_path')->nullable()->comment('证书文件路径');
			$table->string('key_path')->nullable()->comment('支付密钥路径');
			$table->string('nick_name')->default('')->comment('授权方昵称');
			$table->string('nick_name_unicode')->default('')->comment('授权方昵称 unicode 格式');
			$table->string('head_img')->default('')->comment('授权方头像 URL ');
			$table->boolean('service_type_info')->nullable()->comment('授权方公众号类型，0代表订阅号，1代表由历史老帐号升级后的订阅号，2代表服务号');
			$table->boolean('verify_type_info')->nullable()->comment('授权方认证类型，-1代表未认证，0代表微信认证');
			$table->string('user_name')->default('')->comment('授权方公众号的原始ID');
			$table->string('alias')->default('')->comment('授权方公众号所设置的微信号，可能为空');
			$table->string('business_info')->default('')->comment('功能的开通状况 JSON');
			$table->text('func_info', 65535)->nullable()->comment('授权公众号权限列表 JSON');
			$table->string('qrcode_url')->default('')->comment('授权公众号 二维码图片的URL');
			$table->boolean('canceled')->default(0)->comment('该公众号是否已取消授权');
			$table->dateTime('token_should_refresh')->nullable()->comment('如当前时间超过此值, access_token当刷新');
			$table->dateTime('ticket_should_refresh')->nullable()->comment('如当前时间超过此值, jsapi_ticket当刷新');
			$table->string('idc', 30)->nullable()->comment('文档上没写');
			$table->string('principal_name')->nullable()->comment('法人');
			$table->string('signature')->nullable()->comment('公众号描述');
			$table->timestamps();
		});
	}


	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('authorizers');
	}

}
